﻿#include "mainwindow.h"
#include <QPainter>
#include <QDebug>
#include "Shape.h"
#include "Monitor.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    resize(400, 300);
    startTimer(6);
}

MainWindow::~MainWindow()
{

}

void MainWindow::paintEvent(QPaintEvent *)
{
    QPainter painter(this);

    foreach(Performer* per, this->stage.singles)
    {
        painter.drawPixmap(QPointF(10, 10) + per->getSite().toQPointF() + per->getPaint().delta().toQPointF(), per->getPaint().pixmap());
    }

    //painter.setPen(QColor(0,0,255,64));
    //painter.drawRect(10, 10, 300, 200);
    //painter.drawLine((this->stage.active_compo[0]->getSite() + VPoint(10,10)).toQPointF(), (this->stage.active_compo[0]->getSite() + InActStaticPoint + VPoint(10,10)).toQPointF());
}

void MainWindow::timerEvent(QTimerEvent *)
{
    Monitor mon;
    mon.command(stage.active_compo, stage.passive_compo);
    //mon.execute(stage.singles);

    this->update();
}

void MainWindow::mouseMoveEvent(QMouseEvent *event)
{
    stage._mouse->mouseClickOn(VPoint(event->x(), event->y()));
    //stage._mouse->execute();
}

void MainWindow::mousePressEvent(QMouseEvent *event)
{
    stage._mouse->mouseClickOn(VPoint(event->x(), event->y()));
    //stage._mouse->execute();
}

void MainWindow::mouseReleaseEvent(QMouseEvent *)
{
}
